package com.itheima.hello.缓冲流;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;

public class 缓冲输入输出流 {
    public static void main(String[] args) {
        try (
//               Reader fr = new FileReader("helloworld-app\\src\\com\\itheima\\hello\\缓冲流\\itheima.txt");
//             BufferedReader  br = new BufferedReader(fr);//创建一个字符缓冲输入流，底层默认创建一个8K的缓冲池
             BufferedReader br = new BufferedReader(new FileReader("helloworld-app\\src\\com\\itheima\\hello\\缓冲流\\itheima.txt"));
        )
        {
//            char[] buffer = new char[3];
//            int len;
//            while ((len = br.read(buffer)) != -1){
//                System.out.print(new String(buffer,0,len));
//            }
//            System.out.println(br.readLine());

            String line;//用来记录每次读取的一行数据
            while ((line= br.readLine())!=null){
                System.out.println(line);
        }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
